﻿var ns, toast,imageBrowser;
var app = new Vue({
    el: '#app',
    data: {
        form: {
            ID: 0,
            Title: '',
            Content: ''
        },
        previewImage: [],
        imgarr:[],
        IsApproval:0
    },
    methods: {
        get_data: function () {
            var that = this;
            var options = {};
            options.id = that.form.ID;
            toast.loading({
                title: "加载中",
                duration: 2000
            }, function (ret) { });
            ns.post(options, function (succeed, data, err) {
                toast.hide();
                console.log(JSON.stringify(data));
                if (succeed) {  
                    // console.log(JSON.stringify(data));
                    that.form = data;

                    api.sendEvent({
                        name: 'isreadtrue',
                    });
                } else if (err) {
                    api.toast({
                        msg: err,
                        duration: 2000,
                        location: 'bottom'
                    });
                }
            },{
                command: 'App/System/GetNotifyDetail'
            });
        },
        img_browser: function(imgurl) {
            var that = this;
            var imgurls = [];
            imgurls.push(imgurl);
            imageBrowser.openImages({
                imageUrls: imgurls,
                showList: false,
                activeIndex: 0
            });
        },
    }
});

apiready = function () {
    api.parseTapmode();
    imageBrowser = api.require('imageBrowser');
    ns = window.Foresight.Util;
    toast = new auiToast();
    app.form.ID = api.pageParam.id || 0;
    app.IsApproval = api.pageParam.IsApproval;
    app.get_data();

    //点击查看图片
    setTimeout(function () {
        var imageshow = document.getElementsByTagName('img');
        for (var i = 0; i < imageshow.length; i++) {
            imageshow[i].onclick = function (ret) {
                app.img_browser(this.src);
            }
        }
    }, 500);
};